home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4564 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  15.0 KB

  1. From: magicsn@birdland.es.bawue.de (Steffen Haeuser)
  2. Path: eisbaer.bb.bawue.de!birdland.es.bawue.de
  3. Newsgroups: comp.sys.amiga.programmer
  4. Message-ID: <84000305731684920000@BIRDLAND>
  5. X-Mailer: fastnet2rfc V2.0 - (tse) Lunqual%MAB@wsb.freinet.de / Tachy@wsb.freinet.de
  6. Organization: Birdland BBS, Dettingen/Teck, South Germany, +49-7021-862428
  7. Content-Type: text/plain; charset=ISO-8859-1
  8. Subject: rtgmaster c2p Standard Bugfix
  9. Date: 29 Feb 1996 21:28:12
  10.  
  11. urx... i miscounted the Bytes... sorry...
  12. here comes the Bugfix... And of course the c2p function can't free its
  13. own memory, so freeing rs_c2pcode will be done in the CloseRtgScreen
  14. function of rtgmaster.library, NOT in the Expunge...
  15. And the currently selected mode can be found in rs_c2pcurr (see below)
  16.  
  17. The RtgMaster c2p Standard
  18. ==========================
  19.  
  20. rtgmaster.library is a soon to be released ASM written Library for
  21. Graphicsboard AND ECS/AGA compatibility in games and demos. It is
  22. NOT a WB Emulation, but contrary to some WB Emulations it is done
  23. in a way that make that things, that demo/game coders need, EASY
  24. TO DO.
  25.  
  26. Among its features, rtgmaster.library (a Beta version is available
  27. from me, MagicSN@birdland.es.bawue.de), supports a standard for
  28. c2p functions. This will used with the rtgmaster call CallRtgC2P.
  29. CallRtgC2P performs a simple "CopyPixelArray" style function for
  30. Graphics Boards (but does not use the OS, instead it directly
  31. accesses the Video Memory, using longword access where possible),
  32. and performs c2p for ECS/AGA. The c2p is choosable from a file
  33. and the c2p function will be loaded during opening the screen.
  34. This file describes how you can change your c2p algorithm so that
  35. it is usable with rtgmaster.library (you can choose the c2p using
  36. the Screenmode Requester of rtgmaster.library).
  37.  
  38. I myself will soon convert two 68020 optimized and two 68040 optimized
  39. c2p functions. I would be very interested in other people converting
  40. other c2p code, especially interested i would be in 1x2, 2x1 and 2x2
  41. stuff (i do not have such stuff up to now...)
  42.  
  43. Now, let's start... i hope this specification satisfies everybody, as
  44. i really tried hard to support EVERYTHING what is usefull for c2p.
  45.  
  46. Primarily our c2p code is ASM code. You code it, assemble it, and put
  47. it to the directory libs:rtgc2p, with the extension .c2p (a
  48. filename could be libs:rtgc2p/040_1.c2p for example).
  49.  
  50. The c2p file has to have the following structure :
  51.  
  52. Byte 0 :
  53.  
  54.   Bit 0 : Supports AGA     256 Colors
  55.   Bit 1 : "        ECS EHB  64 Colors
  56.   Bit 2 : "        ECS      32 Colors
  57.   Bit 3 : "        ECS      16 Colors
  58.   Bit 4 : Supports 68020
  59.   Bit 5 : Supports 68040
  60.   Bit 6 : Supports 68030
  61.   Bit 7 : Supports 68060
  62.  
  63.   Note : Bit 6 is 0 for 68040
  64.   ONLY c2p. Bit 7 is 0 for stuff that does not run on 060 (as 060 is a bit
  65.   incompatible to the usual stuff...). This is ONLY information given to the
  66.   user in the Screenmode-Requester of rtgmaster.library, it won't be checked.
  67.   You specify 1 if something is supported or not known, 0 if not).
  68.  
  69. Byte 1 :
  70.  
  71.   Bit 0 : Supports 1x1
  72.   Bit 1 : "        1x2
  73.   Bit 2 : "        2x1
  74.   Bit 3 : "        2x2
  75.   Bit 4 : "        2x4
  76.   Bit 5 : "        4x2
  77.   Bit 6 : "        4x4
  78.  
  79.   If your c2p code is called with a mode it does not support, it should
  80.   simply choose another one that it supports. It should not fail.
  81.  
  82. Byte 2 :
  83.  
  84.   Bit 0 : Supports Interleaved Bitmaps
  85.   Bit 1 : Supports Non-Interleaved Bitmaps
  86.   Bit 2 : Needs Initialization
  87.   Bit 3 : Width has to be divisibly by 32
  88.   Bit 4 : Height has to be divisible by 32
  89.   Bit 5 : Supports "Dirty" flag
  90.   Bit 6 : Needs additional buffer of width * height Bytes
  91.   Bit 7 : Supports c2p'ing rectangles smaller than Fullscreen
  92.  
  93. Byte 3 :
  94.  
  95.   Bit 0 : Supports Scrambled Chunky
  96.   Bit 1 : Suppors hardware-hacks (won't be called on NOT ECS/AGA Planar hardware)
  97.   Bit 2 : Runs asynchrone (returns BEFORE c2p is finished)
  98.   Bit 3 : Runs on PowerPC 680x0 emulation (well, future compatibility :) )
  99.   Bit 4 : Supports Power Amiga Planar Hardware
  100.   Bit 5 : Supports CyberGraphX 3 Planar Modes
  101.  
  102.   Bit 3 currently should be 1, as we do not know this ... grin...
  103.   I added Bit 4 to get sure (if Power Amiga will have Planar Modes left).
  104.   Bit 5 is intended for the case that CyberGraphX 3 AGA uses Planar modes.
  105.  
  106. Byte 4-7  : Pointer to a string that describes your code
  107.             (for example "Fast 040 optimized c2p that remembers
  108.             last frame in additional buffer"). Maximum is 255 characters.
  109. Byte 8-11 : Pointer to code for Non-Interleaved Bitmap or 0.
  110. Byte 12-15 : Pointer to code for Interleaved Bitmap or 0.
  111. Byte 16-19 : Pointer to Initialization code or 0.
  112. Byte 20-23 : Pointer to Expunge code or 0.
  113. Byte 24-27 : Length of the .c2p file in Bytes.
  114.  
  115. The initialization code
  116. =======================
  117.  
  118. RtgScreen     in a0.
  119. mode          in d0.
  120.  
  121. RtgScreen is :
  122.  
  123. STRUCTURE RtgScreen,0
  124.   ULONG rs_LibBase        ; Sub-library base for this ID
  125.   UWORD rs_LibVersion     ; Sub-library version for this ID
  126.   UWORD rs_Pad1
  127.   ULONG rs_GraphicsBoard  ; ID
  128.   STRUCT rs_Reserved,20
  129.   ULONG rs_MouseX
  130.   ULONG rs_MouseY
  131.   APTR  rs_c2pcode
  132.   APTR rs_c2pdata
  133.   ULONG rs_c2pcurr  ; Currently selected c2p mode
  134.   ; and here the information for the specific sublibrary
  135.   ; will be. Look at your includes of rtgmaster.library for
  136.   ; more information. Currently ECS/AGA is the only supported
  137.   ; hardware that provides Planar modes.
  138.  
  139.   LABEL rs_SIZEOF
  140.  
  141. Example for RtgScreenAMI (rtgAMI.library for ECS/AGA) :
  142.  
  143. STRUCTURE RtgScreenAMI,0
  144.   STRUCT rsAMI_Header,rs_SIZEOF
  145.   UWORD rsAMI_Locks
  146.   ALIGNLONG
  147.   ULONG rsAMI_ScreenHandle
  148.   ULONG rsAMI_PlaneSize
  149.   ULONG rsAMI_DispBuf      ;Buffer currently displayed
  150.   ULONG rsAMI_ChipMem1
  151.   ULONG rsAMI_ChipMem2
  152.   ULONG rsAMI_ChipMem3
  153.   STRUCT rsAMI_Bitmap1,40
  154.   STRUCT rsAMI_Bitmap2,40
  155.   STRUCT rsAMI_Bitmap3,40
  156.   LABEL rsAMI_SIZEOF
  157.  
  158.  
  159. You will find a lot of stuff here, that could be useful for
  160. your c2p code... an Intuition Screenhandle, the Planesize of the
  161. Bitmap(s), the number of the Buffer currently displayed, the
  162. chipmem addresses of the three buffers and the three Bitmaps
  163. of the screen (remember, rtgmaster.library supports up to
  164. Triple-Buffering). rsAMI_Header is the Above RtgScreen structure.
  165.  
  166. rb_c2pcode which contains a pointer to the stuff in the choosen
  167. .c2p file in memory. The .c2p file will be loaded to memory during
  168. the OpenRtgScreen call. This indicates, that loading the c2p code
  169. has to be done by EVERY rtg sublibrary that supports planar modes.
  170.  
  171. rb_c2pdata which should contain a pointer to anything you allocated
  172. in the initialization code of your c2p. You are in NOW WAY limited
  173. in what you do in the initialization function (but you should return
  174. the memory to the system during expunge. Expunge will be called as
  175. soon as you do a c2p with mode c2p_Expunge. There won't be a c2p called
  176. then, instead only an expunge will be done and rb_c2pdata will be set
  177. to 0. Initialization will be called if a c2p is called and rb_c2pdata
  178. is 0). 
  179. The memory of the c2p function will be freed when the Screen is closed,
  180. BTW. So you won't have to handle this. 
  181.  
  182. Remember : Normally RtgScreenAMI is a private structure to rtgmaster.library,
  183. but you are allowed to use it in c2p functions...
  184.  
  185. The modes : (as defined in include:rtgmaster/rtgmaster.i)
  186.  
  187. c2p_1x1 EQU 1
  188. c2p_1x2 EQU 2
  189. c2p_2x1 EQU 3
  190. c2p_2x2 EQU 4
  191. c2p_2x4 EQU 5
  192. c2p_4x2 EQU 6
  193. c2p_4x4 EQU 7
  194. c2p_Best EQU 8
  195. c2p_Fastest EQU 9
  196. c2p_Selected EQU 10
  197.  
  198. These are the modes that have the "dirty" flag set to 0. For certain
  199. c2p algorithms a dirty flag of 1 indicates that not all 32 pixel units
  200. of the screen need to be redrawn. Best chooses the mode with the
  201. highest resolution, Fastest the one which performs the fastest c2p,
  202. Selected the one that is selected for this system (this stuff is saved in
  203. envarc:rtgmaster/c2pmode, if for example c2pmode is the string c2p_1x1,
  204. then 1x1 with "dirty" set to 0, will be used). BTW, the used c2p function
  205. (its path) is saved in envarc:rtgmaster/c2p. This is a GLOBAL configuration
  206. for your system.
  207.  
  208. c2p_1x1D EQU 11
  209. c2p_1x2D EQU 12
  210. c2p_2x1D EQU 13
  211. c2p_2x2D EQU 14
  212. c2p_2x4D EQU 15
  213. c2p_4x2D EQU 16
  214. c2p_4x4D EQU 17
  215. c2p_BestD EQU 18
  216. c2p_FastestD EQU 19
  217. c2p_SelectedD EQU 20
  218.  
  219. The same, only with "Dirty" set to 1. If a c2p does not support "dirty" flags,
  220. "dirty" is ignored.
  221.  
  222. And, last, but not least :
  223.  
  224. c2p_Expunge EQU 21
  225.  
  226. If the program wants a mode that is not available, use another similar
  227. mode. Do not fail the program because a mode is not found. But return
  228. a c2p_err_Wrong_Pixelmode anyways.
  229.  
  230. The Expunge function
  231. ====================
  232.  
  233. RtgScreen in a0.
  234.  
  235. The c2p function itself
  236. =======================
  237.  
  238. You will have to code one or two functions (interleaved/non-interleaved).
  239. If CallRtgC2P does not find the needed function, but only 0 (if you only
  240. did it interleaved, and the RtgScreen is non-interleaved, for example)
  241. the CallRtgC2P fails with a c2p_err_Interleavedmode error and does not
  242. perform c2p. This includes specifiying a "dirty" mode, if the c2p does
  243. not support "dirty" modes.
  244.  
  245. If the user wanted to do a c2p with only part of the display, but your
  246. c2p only supports Fullscreen c2p, CallRtgC2P will return a c2p_err_Windowsize
  247. error (it will check for this at first, for speed issues, so you could try to
  248. do a partially c2p in an application first, and if that fails, recalculate to
  249. do the stuff fullscreen from now on).
  250.  
  251. If you try to do a c2p with the wrong Colordepth, CallRtgC2P will return
  252. a c2p_err_Wrong_Colordepth error and won't do a c2p.
  253.  
  254. If you try to do a c2p with a wrong width/height for c2p functions that
  255. are only for "divisible by 32" stuff, a c2p_err_divisible will be given,
  256. but the code will TRY to do the c2p anyways. But normally this should not
  257. happen, if you do not hack around with rtgmaster, as not fitting Screenmodes
  258. are filtered out by the Screenmoderequester.
  259.  
  260. A c2p_err_hardware will be given if for example you try to do hardware
  261. hacking c2p on other devices than ECS/AGA (but up to now ECS/AGA is
  262. the only supported Planar Hardware on rtgmaster anyways) or other
  263. similar compatibility problems.
  264.  
  265. For internal errors in your c2p (no memory left...) you might
  266. return c2p_err_internal.
  267.  
  268. If everything worked fine, CallRtgC2P will return 0.
  269.  
  270. The errormessages :
  271.  
  272. c2p_err_Interleavedmode EQU 1
  273. c2p_err_Wrong_Colordepth EQU 2
  274. c2p_err_Wrong_Pixelmode EQU 3
  275. c2p_err_Windowsize EQU 4
  276. c2p_err_divisible EQU 5
  277. c2p_err_hardware EQU 6
  278. c2p_err_internal EQU 7
  279.  
  280. And now finally, the specification of the c2p function itself :
  281.  
  282. a0 : Pointer to the chunky data
  283. a1 : Pointer to Bitplane 0
  284. a2 : Pointer to a Byte containing the Dirty Flag
  285. a3 : Pointer to the RtgScreen Structure
  286. d1 : Planesize : (width*height)/8
  287. a5 : Buffer of width*height Bytes, if needed (should be allocated
  288.      in the initialization function, if Byte 3/Bit 6 is 0, you will
  289.      find 0 in a5... you should specify the "Initialization function
  290.      needed" for EVERY c2p that needs this extra buffer, else you will
  291.      get buggy code.
  292. d0 : Modus
  293. a4 : Pointer to a rectangle (like definded in include:graphics/gfx.i)
  294.      indicating which rectangle to handle if you do not want a Fullscreen
  295.      c2p (but remember, not all c2p functions support this feature,
  296.      this could fail...)
  297. d2 : For asynchrone stuff : Exec Signal
  298.  
  299. Providing the correct Bitmap of the three is already handled by
  300. rtgmaster.library, you won't have to bother about it... you should
  301. restore ALL registers, only d0,d1,a0 and a1 might loose their contents
  302. in your c2p.
  303.  
  304. d2 contains an Exec Signal (an ULONG containing a signal bit). For
  305. asynchrone code this signal has to be set as soon as the c2p is
  306. finished. Synchrone code should set the signal at the end of the
  307. function. Do not ignore the signal !!! Even if you have a synchronce
  308. function !!!
  309.  
  310. The function returns 0, if it worked, or an appropriate errorcode, if
  311. not. Sometimes it might even then doing something if there was an
  312. errorcode (look above).
  313.  
  314. Finally, the specification for CallRtgC2P :
  315.  
  316. rtgmaster.library/CallRtgC2P                                rtgmaster.library/CallRtgC2P
  317.  
  318.    NAME
  319.         CallRtgC2P -- Perform c2p for Planar Screens, CopyRtgPixelArray for Chunky Screens
  320.  
  321.    SYNOPSIS
  322.         int CallRtgC2P(RtgScreen,BufAdr,Array,signal,xpos,ypos,width,height,mode)
  323.          D0              A0        A1     A2    D0     D1   D2   D3    D4     D5
  324.  
  325.         int CallRtgC2P(struct RtgScreen *,APTR,APTR,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG)
  326.  
  327.    FUNCTION
  328.         This function will look what the "standard c2p" for the system is up to now
  329.         (the standard c2p can be choose by a future version of the Rtgmaster Screenmode
  330.         requester, the available c2p algorithms are found in libs:rtgc2p, how own c2p
  331.         algorithms can be added to the system will be explained in the documentation
  332.         of the first version of rtgmaster.library that actually supports CallRtgC2P).
  333.         The function will, if the display is a Planar one, convert the Chunky Data in
  334.         Array to Planar using the choosen c2p algorithm, and display it in the choosen
  335.         Buffer. For Chunky Displays it will instead do the same as CopyRtgChunkyPixel.
  336.         This way a very easy possibility to support both AGA and Graphics Boards without
  337.         having to do "special versions" will be available, if one uses a Fastram Buffer.
  338.  
  339.         I am still looking for c2p algorithms for this function !!! All used c2p algorithms
  340.         should support AGA and additional, it would be fine, if they supported
  341.         1x1,1x2,2x1 and 2x2. If you have fine c2p algorithms, mail me
  342.         (MagicSN@birdland.es.bawue.de).
  343.  
  344.         NOTE : The Array should EXACTLY be as big as specified with Left, Top, Width
  345.         and Height... it should *NOT* be bigger. Up to now the c2p i have do not
  346.         support the feature to do less then fullscreen...
  347.  
  348.         NOTE: Currently you *HAVE TO* use xpos=0 ypos=0 width=<max x> height=<max y>
  349.         Maybe this will change in the future !!!!!!!!!!!!!!
  350.  
  351.         NOTE: Some c2p algorithms might do NOTHING in certain colour depths, chunky modes
  352.         or for interleaved bitmaps. Be careful about this. If the c2p works,
  353.         this function returns 0, otherwise an errorcode.
  354.  
  355.         Principially it COULD support 256, 64 (EHB), 32 or 16 colors and 1x1, 1x2, 2x1,
  356.         2x2,4x2,2x4 and 4x4 (look at the includes). It is also possible to choose the
  357.         FASTEST AVAILABLE, the BEST AVAILABLE mode or the mode that was selected from
  358.         the user as standard mode for his system, using the Screenmode Requester.
  359.  
  360.         Before quitting the program you should call this function with a mode
  361.         of c2p_Expunge to free used memory in initializations.
  362.  
  363.         If the user did not specify a standard c2p, this function will use the fastest
  364.         available mode.
  365.  
  366.         The signal indicates (for asynchrone c2p) that the c2p has done. For synchrone
  367.         ones it is set after quitting the function.
  368.  
  369.         In mode you specify which c2p mode to use.
  370.  
  371.         For Graphics Boards, ALWAYS 1x1 is used.
  372.  
  373.         IMPLEMENTED WITH SUBLIBRARIES WITH AT LEAST VERSION 2.0 (none up to now...)
  374.  
  375.    INPUTS
  376.         RtgScreen - The RtgScreen to use.
  377.         BufAdr - The address of the buffer to use
  378.         Array - The fastram buffer
  379.         Left - The x position on the Bitmap of RtgScreen where to put the stuff
  380.         Top - The y position
  381.         Width - The Width of the stuff
  382.         Height - The Height of the stuff
  383.